package com.customization.api.e9sso.service.impl;

import com.customization.api.e9sso.cmd.*;
import com.customization.api.e9sso.service.SsoTokenService;

import com.customization.commons.Console;
import com.engine.core.impl.Service;
import weaver.conn.RecordSet;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public class SsoTokenServiceImpl extends Service implements SsoTokenService {

    @Override
    public Map<String, Object> gettokenInfo(Map<String, Object> params) {
        boolean is1912=false;
        String sql = "select CVERSION from  license  where  CVERSION='9.00.1912.06'";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        if (rs.next()) {
            is1912=true;
        }
        if(is1912){
            return   commandExecutor.execute(new SsoTokenCmd(user,params));
        }else{
            return   commandExecutor.execute(new SsoTokenCmd4Kb202008(user,params));
        }

    }

    @Override
    public Map<String, Object> sendMsg(Map<String, Object> params) {
        return commandExecutor.execute(new SendMsgCmd(user,params));
    }

    @Override
    public Map<String, Object> updateStatus4Bz(Map<String, Object> params) {
        return commandExecutor.execute(new UpdateStatus4BzCmd(user,params));
    }

    @Override
    public Map<String, Object> dispatch(HttpServletRequest request) {
        boolean is1912=false;
        String sql = "select CVERSION from  license  where  CVERSION='9.00.1912.06'";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        if (rs.next()) {
            is1912=true;
        }
        if(is1912){
          return commandExecutor.execute(new DispatchSSFCmd(user,request));
        }else{
            return commandExecutor.execute(new DispatchSSFCmd4Kb202008(user,request));
        }
    }


    @Override
    public Map<String, Object> reject(HttpServletRequest request) {
        boolean is1912=false;
        String sql = "select CVERSION from  license  where  CVERSION='9.00.1912.06'";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        if (rs.next()) {
            is1912=true;
        }
        if(is1912){
            return commandExecutor.execute(new RejectCmd(user, request));
        }else {
            return commandExecutor.execute(new RejectCmd4Kb202008(user, request));
        }
    }


    @Override
    public Map<String, Object> submit(HttpServletRequest request) {
        boolean is1912=false;
        String sql = "select CVERSION from  license  where  CVERSION='9.00.1912.06'";
        RecordSet rs = new RecordSet();
        rs.executeQuery(sql);
        if (rs.next()) {
            is1912=true;
        }
        if(is1912){
            return commandExecutor.execute(new SubmitCmd(user, request));
        }else{
            return commandExecutor.execute(new SubmitCmd4Kb202008(user, request));
        }
    }

    @Override
    public Map<String, Object> getRequestBaseInfo(Map<String, Object> params) {
        return commandExecutor.execute(new GetRequestBaseInfoCmd(user,params));
    }

    @Override
    public Map<String, Object> getWorkflowBase(Map<String, Object> params) {
        return commandExecutor.execute(new getWorkflowBaseCmd(user,params));
    }

    @Override
    public Map<String, Object> getToDoWorkflowRequestList(Map<String, Object> params) {
        return commandExecutor.execute(new getToDoWorkflowRequestListCmd(user,params));
    }


    @Override
    public Map<String, Object> gethrmSapCompanyList(Map<String, Object> params) {
        return commandExecutor.execute(new GetHrmSapCompanyListCmd(user,params));
    }

    @Override
    public Map<String, Object> forwardRequest(Map<String, Object> params) {
        return commandExecutor.execute(new ForwardRequestCmd(user,params));
    }

    public Map<String, Object> requestDetailImport(HttpServletRequest var1) {
        return (Map)this.commandExecutor.execute(new CusRequestDetailImportCmd(var1, this.user));
    }
}
